/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package biz;

import dao.UserDetailDAO;
import entity.UserDetail;
import java.sql.SQLException;
import java.util.ArrayList;


/**
 *
 * @author Young Ran
 */
public class UserDetailBO {
    
    //DISPLAY USER DETAILS:
    public ArrayList<UserDetail> getAllUserDetail() throws SQLException{
        return new UserDetailDAO().getAllUserDetail();
    }
    public ArrayList<UserDetail> getAllUnapprovedUserDetail() throws SQLException{
        return new UserDetailDAO().getAllUnapprovedUserDetail();
    }
    public UserDetail getByUName(String username) throws SQLException
    {
        return new UserDetailDAO().getByUName(username).get(0);
    }
    
    public void addUserDetail(UserDetail item) throws SQLException
    {
        new UserDetailDAO().addUserDetail(item);
    }
    
    public void approveUser(int userId) throws SQLException
    {
        new UserDetailDAO().approveUser(userId);
    }
    
    public void editUserDetail(UserDetail item) throws SQLException{
        new UserDetailDAO().editUserDetail(item);
    }
    
    public String getUName(int id) throws SQLException
    {
        ArrayList<UserDetail> data = new UserDetailDAO().getAllUserDetail();
        for (UserDetail item : data) {
            if(item.getId()==id)
            {
                return item.getUsername();
            }
        }
        return "";
    }
}
